class Square:
    def __init__(self, width):
        self.__width = width
        self.__area = None

    @property
    def width(self):
        return self.__width

    @width.setter
    def width(self, num):
        self.__width = num
        # 有变化，清空“缓存”
        self.__area = None

    # 实现类似缓存的效果
    @property
    def area(self):
        if self.__area is None:
            print("计算调用")
            self.__area = self.__width * self.__width
        return self.__area


s = Square(13)
print(s.area)
print()
print(s.area)
s.width = 6
print(s.area)

